<template>
  <div class="group-buy">
    <h1>旅游团购</h1>
    <div v-if="services.length === 0" class="no-data">
      暂无团购项目
    </div>
    <div v-else class="service-grid">
      <div v-for="service in services" :key="service.id" class="service-card" @click="goToDetail(service.id)">
        <div class="service-cover">
          <img :src="service.imageUrl" :alt="service.name">
        </div>
        <div class="service-info">
          <h3>{{ service.name }}</h3>
          <p class="description">{{ service.description }}</p>
          <div class="meta-info">
            <span class="city">{{ service.city }}</span>
            <span class="type">{{ service.type }}</span>
          </div>
          <div class="price-info">
            <span class="price">¥{{ service.price }}</span>
            <div class="rating" v-if="service.averageRating">
              <el-rate v-model="service.averageRating" disabled show-score />
              <span class="comment-count">({{ service.commentCount }}条评价)</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useGroupBuy } from '@/ts/pages/group-buy'
import '@/css/pages/group-buy.css'

const { services, goToDetail } = useGroupBuy()
</script> 